package com.oa.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.oa.bean.Schedules;
import com.oa.dao.SchedulesDao;

public class SchedulesDaoImpl 
	extends CommonDao<Schedules> 
	implements SchedulesDao{

	@Override
	public List<Schedules> getUserSchedules(String userName) {
		String sql="select * from schedules where createUser=?";
		List<Schedules> schedules=new ArrayList<Schedules>();
		try {
			open_db();
			pst=conn.prepareStatement(sql);
			pst.setString(1, userName);
			rs=pst.executeQuery();
			while (rs.next()) {
				Schedules s=new Schedules();
				s.setBeginTime(rs.getTimestamp("beginTime"));
				s.setTitle(rs.getString("title"));
				schedules.add(s);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			close_db();
		}
		return schedules;
	}

}
